﻿/***********************************************************************
 * <copyright file="AccordionExtension.cs" company="BUCA JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   LinhMC
 * Email:    linhmc@buca.vn
 * Website:
 * Create Date: Thursday, November 14, 2013
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/
using System;
using System.Linq;
using System.Web.Mvc;

namespace EasyUIMvc
{
    public class AccordionExtension:ExtensionBase
    {
        private readonly AccordionSettings _settings;

        public AccordionExtension(AccordionSettings settings)
        {
            _settings = settings;
        }


        public override string GetScripts()
        {
            throw new NotImplementedException();
        }

        public override MvcHtmlString GetHtml()
        {
            var accordion = GetTopTag("div", "easyui-accordion", _settings);
            accordion.MergeAttribute("style", _settings.Style);
           
            for (int i = 0; i < _settings.Titles.Count(); i++)
            {
                var innerButtonDiv = GetInnerTag("div", "", _settings.Titles[i], _settings.AccordionIcon[i], _settings.InnerStyle[i]);
                accordion.InnerHtml += innerButtonDiv;
            }

            return MvcHtmlString.Create(accordion.ToString());

        }
    }

    public class AccordionSettings : SettingsBase
    {
        public string Style { get; set; }
        public string[] Titles { get; set; }
        public string[] Contents { get; set; }
        public string[] AccordionIcon { get; set; }
        public string[] InnerStyle { get; set; }
    }
}
